# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-otr
_pkgname=otr
pkgver=0.3.10
pkgrel=1
pkgdesc="Off the record implementation purely in OCaml"
url="https://github.com/hannesm/ocaml-otr"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="
	ocaml-runtime
	ocaml-astring
	ocaml-base64
	ocaml-cstruct
	ocaml-mirage-crypto
	ocaml-sexplib0
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-astring-dev
	ocaml-base64-dev
	ocaml-cstruct-dev
	ocaml-mirage-crypto-dev
	ocaml-sexplib0-dev
	"
makedepends="$depends_dev dune ocaml"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/hannesm/ocaml-otr/releases/download/v$pkgver/otr-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
24eee63e54c29e27d90718fe764178d5ee8b9fa599c7ca25b042e57b2442501089c51f11656315949f60e0362f86f743597c74dd968c4d3472e18c4def5179ba  ocaml-otr-0.3.10.tar.bz2
"
